/*
 * @Author: your name
 * @Date: 2020-02-26 14:59:13
 * @LastEditors: komons
 * @LastEditTime: 2020-02-26 15:05:14
 * @Description: 默认GET请求的函数
 * @FilePath: \form-builderc:\Komons\学习\visualization\src\utils\api\defaultApi.js
 */
import axios from "axios";
import config from "src/config";

export default function getDataApi(urlType) {
  let url = config.api + urlType;
  if (config.isMock) {
    url += "?mock=true";
  }
  return new Promise((resolve, reject) => {
    axios
      .get(url)
      .then(res => {
        if (res.status === 200 && res.data.err === 0) {
          resolve(res.data.dataList);
        } else {
          reject(res);
        }
      })
      .catch(err => {
        reject(err);
      });
  });
}
